<?php
/*
Plugin Name: Various custom functions
Description: Add some custom functions.
Author: Manuel EVENO
Version: 0.2
Author URI: http://mektoub.free.fr/
*/

if (XMLRPC_REQUEST == true) {
	require "xmlrpc-extras.php";
}

function my_editor_default_content( $content ) {
	$content = "D&eacute;but de l'article\n<!--more-->\nArticle\n<hr/>\nFin de l'article";
	return $content;
}

add_filter( 'default_content', 'my_editor_default_content' );

/*
function widget_archives_args_filter( $args ) {
	$args['type'] = 'yearly';
	return $args;
}

add_filter('widget_archives_args', 'widget_archives_args_filter');
*/

function enhance_wp_tag_cloud($content) {
	return '<p align="center">' . $content . '</p>';
}

add_filter( 'wp_tag_cloud', 'enhance_wp_tag_cloud');

/*On crée une fonction qui va écrire un bout de HTML, en l'occurrence l'insertion du favicon souhaité */
function changeFaviconInAdmin() {
	echo '<link rel="shortcut icon" type="image/ico" href="' . get_bloginfo('wpurl') . '/wp-content/themes/tribu/favicon.ico" />';
}

/* On l'ajoute en utilisant le hook "admin_head" */
add_action( 'admin_head', 'changeFaviconInAdmin' );

### Function: Insert Video
function insert_video($file, $width, $height)
{
    if ($width == '')
    {
        $width = '320';
    }
    if ($height == '')
    {
        $height = '240';
    }
	$url = "http://mektoub.free.fr/blog/wp-content/video/".$file;
	$result = "\n";
	$result = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"\n";
	$result .= " codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\"\n";
	$result .= " width=\"".$width."\" height=\"".$height."\"\n";
	$result .= " id=\"AnoukDanse\" align=\"middle\">\n";
	$result .= "<param name=\"allowScriptAccess\" value=\"sameDomain\" />\n";
	$result .= "<param name=\"FlashVars\" value=\"&autoStart=false&file=$url\" />\n";
	$result .= "<param name=\"movie\" value=\"/blog/wp-content/video/flvplayer.swf\" />\n";
	$result .= "<param name=\"quality\" value=\"high\" />\n";
	$result .= "<param name=\"wmode\" value=\"transparent\" />\n";
	$result .= "<embed src=\"/blog/wp-content/video/flvplayer.swf\" flashvars=\"&autoStart=false&file=$url\"\n";
	$result .= " quality=\"high\" wmode=\"transparent\"\n";
	$result .= " width=\"".$width."\" height=\"".$height."\"\n";
	$result .= " name=\"Video\" align=\"middle\" allowScriptAccess=\"sameDomain\"\n";
	$result .= " type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />\n";
	$result .= "</embed>\n";
	$result .= "</object>\n";
	return $result;
}

### Function: Place Video In Content
function place_video($content)
{
    $content = preg_replace( "/\[video=([a-zA-Z0-9._-]+)(?:\\swidth=(\d+)\sheight=(\d+)){0,1}]/e", "insert_video('\\1','\\2','\\3')", $content);
    return $content;
}
add_filter('the_content', 'place_video');

?>
